Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding integration tests to checksums #27345

Merged
merged 5 commits into from
Mar 17, 2017

Conversation

SergioBertolinSG
Copy link
Contributor

Requires #27097

@mention-bot
Copy link

@SergioBertolinSG, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @PVince81 and @bartv2 to be potential reviewers.

@SergioBertolinSG
Copy link
Contributor Author

SergioBertolinSG commented Mar 9, 2017

These tests are removed and will be added when copy returns the checksum. Currently they fail.

They require #26584 to be done before.

Scenario: Copying a file with checksum should return the checksum in the propfind
    Given using old dav path
    And user "user0" exists
    And user "user0" uploads file "data/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
    When User "user0" copies file "/myChecksumFile.txt" to "/myChecksumFileCopy.txt"
    And user "user0" request the checksum of "/myChecksumFileCopy.txt" via propfind
    Then The webdav checksum should match "SHA1:3ee962b839762adb0ad8ba6023a4690be478de6f"

  Scenario: Copying file with checksum should return the checksum in the download header
    Given using old dav path
    And user "user0" exists
    And user "user0" uploads file "data/textfile.txt" to "/myChecksumFile.txt" with checksum "MD5:d70b40f177b14b470d1756a3c12b963a"
    When User "user0" copies file "/myChecksumFile.txt" to "/myChecksumFileCopy.txt"
    And user "user0" downloads the file "/myChecksumFileCopy.txt"
    Then The header checksum should match "SHA1:3ee962b839762adb0ad8ba6023a4690be478de6f"

@SergioBertolinSG
Copy link
Contributor Author

These tests where removed from webdav-related.feature and needs to be added here:

        Scenario: Upload chunked file where checksum does not match
                Given using new dav path
                And user "user0" exists
                And user "user0" creates a new chunking upload with id "chunking-42"
                And user "user0" uploads new chunk file "2" with "BBBBB" to id "chunking-42"
                And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42" with checksum "SHA1:f005ba11"
                And user "user0" uploads new chunk file "1" with "AAAAA" to id "chunking-42"
                And user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt"
                Then the HTTP status code should be "400"

        Scenario: Upload a file where checksum does not match
                Given user "user0" exists
                And file "/chksumtst.txt"  does not exist for user "user0"
                And user "user0" uploads file with checksum "SHA1:f005ba11" and content "Some Text" to "/chksumtst.txt"
                Then the HTTP status code should be "400"

        Scenario: Upload a file where checksum does match
                Given user "user0" exists
                And file "/chksumtst.txt"  does not exist for user "user0"
                And user "user0" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/chksumtst.txt"
                Then the HTTP status code should be "201"

        Scenario: Uploaded file should have the same checksum when downloaded
                Given user "user0" exists
                And file "/chksumtst.txt"  does not exist for user "user0"
                And user "user0" uploads file with checksum "SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399" and content "Some Text" to "/chksumtst.txt"
                When Downloading file "/chksumtst.txt" as "user0"
                Then The following headers should be set
                        | OC-Checksum | SHA1:ce5582148c6f0c1282335b87df5ed4be4b781399 |

@SergioBertolinSG SergioBertolinSG force-pushed the inttest-checksums-from-26655_ComputeChecksum2 branch from e545b5f to 7b5fc8b Compare March 10, 2017 09:44
@PVince81
Copy link
Contributor

10:47:19 Using database oc_autotest3
10:47:19 Setup environment for mysqlmb4 testing on local storage ...
10:47:19 Fire up the mysql docker
10:47:20 Waiting for MySQL(utf8mb4) initialisation ...
10:57:22 ........................................................................................................................................................................................................
10:57:22 [ERROR] Waited 600 seconds, no response
10:57:22 Kill the docker 9b7dee09bda11058a69097640488fc4b31fde0e70c0f8a395416367bdce21356
10:57:22 9b7dee09bda11058a69097640488fc4b31fde0e70c0f8a395416367bdce21356
10:57:22 9b7dee09bda11058a69097640488fc4b31fde0e70c0f8a395416367bdce21356
10:57:22 Makefile:177: recipe for target 'test-php' failed

@SergioBertolinSG SergioBertolinSG force-pushed the inttest-checksums-from-26655_ComputeChecksum2 branch from 7b5fc8b to 2ba31b6 Compare March 10, 2017 11:44
$request = $this->client->createRequest(
public function userCopiedFileTo($user, $source, $destination) {
$client = new Client();
$request = $client->createRequest(
'MOVE',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy does a move ? 🤕

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thats why I removed copy tests #27345 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll modify this function.

public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $checksum)
{
public function userUploadsChunkFileOfWithToWithChecksum($user, $num, $total, $data, $destination, $checksum) {
//$client = new Client();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

And user "user0" uploads chunk file "2" of "3" with "BBBBB" to "/myChecksumFile.txt" with checksum "MD5:45a72715acdd5019c5be30bdbb75233e"
And user "user0" uploads chunk file "3" of "3" with "CCCCC" to "/myChecksumFile.txt" with checksum "MD5:45a72715acdd5019c5be30bdbb75233e"
When user "user0" downloads the file "/myChecksumFile.txt"
Then The header checksum should match "SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check the MD5 ? I see it's passed at upload time ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean add another check there?

Then The header checksum should match "MD5:45a72715acdd5019c5be30bdbb75233e"

This fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Why does this fail ? Is the MD5 wrong ? Please investigate.

Or alternatively remove the MD5 from this test as you are testing the computed checksum, not the passed checksum.

Then make a separate test that checks if the stored checksum as passed from the client works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it fails because the sha1 works:

Expected MD5:45a72715acdd5019c5be30bdbb75233e, got SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we return multiple checksums anyway ? Maybe you need to adjust the checking code to pick the matching type and compare that one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just one:

[oc-checksum] => Array
│ (
│ [0] => SHA1:acfa6b1565f9710d4d497c6035d5c069bd35a8e8
│ )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But aren't we computing three different checksum types ? Why only return one then ?

cc @IljaN

Copy link
Contributor

@IljaN IljaN Mar 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PVince81
Yeah we are computing three different sums. But I decided to return one. Actually I am not sure anymore what my reasoning was. I think because existing tests expected one sum in the webdav body and I was afraid to break some protocols.

I suppose we could easily change that to have multiple checksums (space seperated) returned on a PROPFIND.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergioBertolinSG PROPFIND nows returns all checksums, I also modified the tests in checksums.feature accordingly

Copy link
Contributor Author

@SergioBertolinSG SergioBertolinSG Mar 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IljaN Great, thanks.

(It is really needed to compute three checksums? I guess you already discuss that, but seems weird)

@SergioBertolinSG
Copy link
Contributor Author

👍 for last changes

@PVince81 PVince81 merged commit fe3e383 into master Mar 17, 2017
@PVince81 PVince81 deleted the inttest-checksums-from-26655_ComputeChecksum2 branch March 17, 2017 07:57
And user "user0" exists
And file "prueba_cksum.txt" with text "Test file for checksums" is created in local storage
When user "user0" downloads the file "/local_storage/prueba_cksum.txt"
When user "user0" downloads the file "/local_storage/prueba_cksum.txt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergioBertolinSG I am doing some refactoring and noticed that this line is duplicated.
When I remove 1 copy, the check for header checksum below fails (it cannot find the file).
Do you remember why this download needs to be done twice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@phil-davis It might be because checksum is computed on first download for files which have none.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, thanks. I see that the previous test step creates the file directly on the local storage (bypassing ownCloud). So the first download triggers the checksum calculation.
I will make a comment in the feature file while refactoring so the next person does not have to research this.

@lock
Copy link

lock bot commented Aug 1, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants